<?php include "../public/header.php"?>
<?php include "../public/header_public.php"?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title">选择项目信息</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <button class="layui-btn layui-btn-sm btn-dark marginr5" type="button" id="submit">确定</button>
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>


<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目类型</label>
                        <div class="layui-input-block">
                            <div id="bidtype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">项目所在地</label>
                        <div class="layui-input-block">
                            <input type="text" name="areas" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">招标方</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhaoname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">招标方联系方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhaotel" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">招标方式</label>
                        <div class="layui-input-block">
                            <div id="zhaotype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">项目属性：</label>
                        <div class="layui-input-block">
                            <select id="business" name="business" lay-filter="business">
                                <option value="">请选择</option>
                                <option value="1">自营</option>
                                <option value="2">联营</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">经营备案人</label>
                        <div class="layui-input-block">
                            <input type="text" name="jingbeier" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">信息来源</label>
                        <div class="layui-input-block">
                            <input type="text" name="xinlai" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">信息来源</label>
                        <div class="layui-input-block">
                            <input type="text" name="xinlai" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">报名截止时间</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="enddt_bao" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">投标截止时间</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="enddt_tou" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">开标时间</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="kaidt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">投标负责人</label>
                        <div class="layui-input-block">
                            <input type="text" name="touer_name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">投标单位</label>
                        <div class="layui-input-block">
                            <div id="touunit" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">参投说明</label>
                        <div class="layui-input-block">
                            <input type="text" name="toushuo" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">联营单位</label>
                        <div class="layui-input-block">
                            <input type="text" name="lianunit" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">是否收费：</label>
                        <div class="layui-input-block">
                            <select id="isfei" name="isfei" lay-filter="isfei">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">费用收取说明</label>
                        <div class="layui-input-block">
                            <input type="text" name="feishuo" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    // 单选多选分类 默认单选 choose_type传值为多选
    var choose_type = getQueryVariable('choose_type');
    if(choose_type === undefined || choose_type === false){
        choose_type = 'radio';
    }else{
        choose_type = 'checkbox';
    }

    // 用证使用
    var apply_type = getQueryVariable('apply_type');
    if(apply_type === undefined || apply_type === false){
        apply_type = '';
    }

    var parent_dom = getQueryVariable('dom');
    var parent_page = getQueryVariable('page');
    var param_business = getQueryVariable('business') || '';
    var param_zhongluo = getQueryVariable('zhongluo') || '';


    var currButAuth, currTabData, sea_type='', sea_bidding_type='',sea_qualification='',sea_sign_type='',sea_bid_type='',
        sea_bid_evaluation='', queryStatus = 0;
    layui.use(['table','form','soulTable'], function () {
        var table = layui.table, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            sea_type=''; sea_bidding_type='';sea_qualification='';sea_sign_type='';sea_bid_type='';sea_bid_evaluation='';
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        $("#cols_table").hide();
        $("#export_table").hide();
        setSouTableExport('投标');
        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_opt_get_bid_page_certuse),where: {apply_type:apply_type, business:param_business,zhongluo:param_zhongluo}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response
            ,contextmenu:get_table_contextmenu(soulTable)
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);


                xmselect_dan('bidtype', res.data.bidtype, res.data.is_bidtype, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                xmselect_dan('zhaotype', res.data.zhaotype, res.data.is_zhaotype, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                xmselect_dan('touunit', res.data.touunit, res.data.is_touunit, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            ,cols: [[
                {type: choose_type, fixed: 'left'}
                ,{type: 'numbers',title:'序号',fixed:'left'}
                ,{field: 'state_name', title: '项目状态'}
                ,{field: 'enddt_bao', title: '报名截止时间'}
                ,{field: 'enddt_tou', title: '投标截止时间'}
                ,{field: 'kaidt', title: '开标时间'}
                ,{field:'name',title:'项目名称',templet: function(d){
                        return '<span class="colorlan" onclick="openPage(\'../bid/show.php?id='+d.id+'\')">'+d.name+'</span>';
                    }}
                ,{field: 'number', title: '项目编号'}
                ,{field: 'bidtype_name', title: '项目类型'}
                ,{field: 'areas', title: '项目所在地'}
                ,{field: 'addr', title: '项目地址'}
                ,{field: 'zhaoname', title: '招标方'}
                ,{field: 'zhaotel', title: '招标方联系方式'}
                ,{field: 'zhaotype_name', title: '招标方式'}
                ,{field: 'chanid_name', title: '项目所属单位'}
                ,{field: 'business_name', title: '项目属性'}
                ,{field: 'lianunit', title: '联营单位'}
                ,{field: 'touer_name', title: '投标负责人'}
                ,{field: 'bianer_name', title: '标书制作人'}
                ,{field: 'jingbeier', title: '经营备案人'}
                ,{field: 'xinlai', title: '信息来源'}
                ,{field: 'gai', title: '项目概况'}
                ,{field: 'explain', title: '备注'}
                ,{field: 'created_user_name', title: '创建人'}
                ,{field: 'created_at', title: '创建时间'}
            ]]
            , done: function (res) {
                soulTable.render(this);
                show_tab_but(currTabData);
            }
        });
        listTableSearch(form, table);

        $('#submit').on('click', function () {
            var checkStatus = layui.table.checkStatus('datalist');
            var data = checkStatus.data;
            if(data.length < 1){
                facade.error("请选择数据");return false;
            }

            if(parent_page === 'bid_task'){
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'parent_page\')">×</span></button>';
                $('#'+ parent_dom, parent.document).html(str);

            } else if(parent_page === 'cert_use'){
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                $('#'+ parent_dom, parent.document).html(str);
                parent.formValid(parent_dom);

                var cert_list = data[0].cert_use;
                var cert_str = '';
                for(var i=0;i<cert_list.length;i++){
                    // 设置在用证书
                    cert_str += '<tr>';
                    cert_str += '<td style="width: 45px;">'+(i+1)+'</td>';
                    cert_str += '<td>' + cert_list[i].place +
                        '<input type="hidden" class="place" value="'+cert_list[i].place+'">' +
                        '<input type="hidden" class="cert_id" value="'+cert_list[i].cert_id+'">' +
                        '<input type="hidden" class="id" value="'+cert_list[i].id+'">' +
                        '</td>';
                    cert_str += '<td class="cert_name">'+cert_list[i].cert_name+'</td>';
                    cert_str += '<td>'+cert_list[i].cert_number+'</td>';
                    cert_str += '<td>'+cert_list[i].cert_major+'</td>';
                    cert_str += '<td class="person_name">'+cert_list[i].person_name+'</td>';
                    cert_str += '<td>'+cert_list[i].use_name+'</td>';
                    cert_str += '<td>'+cert_list[i].com_name+'</td>';
                    cert_str += '<td class="issuo_status">'+cert_list[i].issuo_name+'</td>';
                    cert_str += '<td>';
                    cert_str += '<select class="layui-select opt_select" lay-filter="opt_select">';
                    cert_str += '<option value="0">不变更</option>';
                    cert_str += '<option value="1">替换</option>';
                    cert_str += '<option value="2">停用</option>';
                    cert_str += '</select>';
                    cert_str += '</td>';
                    cert_str += '</tr>';
                }
                $("#optDiv #opt_tbody" , parent.document).html(cert_str);
                parent.render_from();
            }  else if(parent_page === 'engin'){
                $('#name', parent.document).val(data[0].name);
                $('#number', parent.document).val(data[0].number);
                if(!param_business){
                    if(data[0].business == 1){
                        $('.business1', parent.document).prop('checked', true);
                        $("#lian_unitDiv", parent.document).addClass('layui-hide');
                    }else{
                        $('.business2', parent.document).prop('checked', true);
                        $("#lian_unitDiv", parent.document).removeClass('layui-hide');
                    }
                }
                parent.show_engintype(data[0].old_type);



                var chanid_str = '<div class="tags">';
                chanid_str += '<div ' +
                    'title="'+data[0].chanid_name+'" '+
                    'data-id="'+data[0].chanid+'" '+
                    'data-part="dept" '+
                    '>';
                chanid_str += data[0].chanid_name+'</div>';
                chanid_str += '<i class="layui-icon" onclick="closeTanTag(this)">&#x1006;</i></div>';
                $('#chanid', parent.document).html(chanid_str);

                parent.show_areas(data[0].areas);
                $('#addr', parent.document).val(data[0].addr);
                $('#expectfee', parent.document).val(data[0].kai_fee);
                parent.show_zhaotype(data[0].zhaotype);

                parent.render_from();
            } else if(parent_page === 'engin_bond_jiao'){
                $('#money', parent.document).val(data[0].bond_money);
                $('#zhai', parent.document).val('投标保证金-'+data[0].name);
                $('#bond_enddt', parent.document).val(data[0].bond_enddt);
                $('#bond_tuidt', parent.document).val(data[0].bond_tuidt);

                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                $("#"+parent_dom , parent.document).html(str);

                parent.formValid(parent_dom);
            } else if(parent_page === 'bid_sum'){
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'parent_page\')">×</span></button>';
                $('#'+ parent_dom, parent.document).html(str);

                $('#bid_inviter', parent.document).val(data[0].zhaoname);
                $('#address', parent.document).val(data[0].addr);
                $('#bid_money', parent.document).val(data[0].yufee);
                $('#plan_day', parent.document).val(data[0].plan_day);
                $('#kaidt', parent.document).val(data[0].kaidt);
                $('#bid_evaluation', parent.document).val(data[0].bid_evaluation);
                $('#open_result', parent.document).val(data[0].state_name);
                $('#fuzer', parent.document).val(data[0].touer_name);

            } else if(parent_page === 'bid_book'){
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                $("#"+parent_dom , parent.document).html(str);
                $('#business', parent.document).val(data[0].business_name);
                $('#enddt_tou', parent.document).val(data[0].enddt_tou);
            } else if(parent_page === 'bid_grant_book'){
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                $("#"+parent_dom , parent.document).html(str);
                $('#bid_number', parent.document).val(data[0].number);
            }

            else{
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                $("#"+parent_dom , parent.document).html(str);
                parent.formValid(parent_dom);
            }
            layer_close();
        });
    });
</script>
</body>
</html>
